package com.ruoyi.business.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.business.mapper.JtUserAddressMapper;
import com.ruoyi.business.domain.JtUserAddress;
import com.ruoyi.business.service.IJtUserAddressService;
import com.ruoyi.common.core.text.Convert;

/**
 * 用户地址Service业务层处理
 * 
 * @author Alan Zhang
 * @date 2025-03-29
 */
@Service
public class JtUserAddressServiceImpl implements IJtUserAddressService 
{
    @Autowired
    private JtUserAddressMapper jtUserAddressMapper;

    /**
     * 查询用户地址
     * 
     * @param addressId 用户地址主键
     * @return 用户地址
     */
    @Override
    public JtUserAddress selectJtUserAddressByAddressId(Long addressId)
    {
        return jtUserAddressMapper.selectJtUserAddressByAddressId(addressId);
    }

    /**
     * 查询用户地址列表
     * 
     * @param jtUserAddress 用户地址
     * @return 用户地址
     */
    @Override
    public List<JtUserAddress> selectJtUserAddressList(JtUserAddress jtUserAddress)
    {
        return jtUserAddressMapper.selectJtUserAddressList(jtUserAddress);
    }

    /**
     * 新增用户地址
     * 
     * @param jtUserAddress 用户地址
     * @return 结果
     */
    @Override
    public int insertJtUserAddress(JtUserAddress jtUserAddress)
    {
        jtUserAddress.setCreateTime(DateUtils.getNowDate());
        return jtUserAddressMapper.insertJtUserAddress(jtUserAddress);
    }

    /**
     * 修改用户地址
     * 
     * @param jtUserAddress 用户地址
     * @return 结果
     */
    @Override
    public int updateJtUserAddress(JtUserAddress jtUserAddress)
    {
        return jtUserAddressMapper.updateJtUserAddress(jtUserAddress);
    }

    /**
     * 批量删除用户地址
     * 
     * @param addressIds 需要删除的用户地址主键
     * @return 结果
     */
    @Override
    public int deleteJtUserAddressByAddressIds(String addressIds)
    {
        return jtUserAddressMapper.deleteJtUserAddressByAddressIds(Convert.toStrArray(addressIds));
    }

    /**
     * 删除用户地址信息
     * 
     * @param addressId 用户地址主键
     * @return 结果
     */
    @Override
    public int deleteJtUserAddressByAddressId(Long addressId)
    {
        return jtUserAddressMapper.deleteJtUserAddressByAddressId(addressId);
    }

    /**
     * 取消地址默认
     * @param userId
     * @return
     */
    @Override
    public int updateJtUserAddressCancelDefault(Long userId) {
        return jtUserAddressMapper.updateJtUserAddressCancelDefault(userId);
    }
}
